#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int get_number() {
    string line;
    int num;
    while (true) {
        cout << " a number between 1 and 100: ";
        getline(cin, line);
        stringstream ss(line);
// 读取str并复制到ss
        if (ss >> num) {

            if (num >= 1 && num <= 100) {
                return num;
            } else {
                cout << "Error: Number must be between 1 and 100" << endl;
            }
        } else {
            cout << "Error: Please enter a valid number" << endl;
        }
    }
}

int main() {
    int valid_number = get_number();
    cout << "You entered: " << valid_number << endl;
    return 0;
}